﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Json_Test {
    class CustomSerializer : ComputerBeacon.Json.Serializer {
        public override void SerializeObject(StringBuilder sb, object o) {
            if (o.GetType() == typeof(DateTime)) SerializeObject(sb, ((DateTime)o).ToString());
            else base.SerializeObject(sb, o);
        }

        public override object DeserializeObject(Type targetType, object jsonValue) {
            if (targetType == typeof(DateTime) && jsonValue.GetType() == typeof(string)) return Convert.ToDateTime(jsonValue as string);
            return base.DeserializeObject(targetType, jsonValue);
        }
    }
}
